﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;

namespace Model.EntityModel.SysModel
{
    /// <summary>
    /// 属性权限规则表（ABAC核心）
    ///</summary>
    [SugarTable("ATTRIBUTE_RULE")]
    public class AttributeRule
    {
        [SugarColumn(ColumnName = "ID", IsPrimaryKey = true)]
        public string Id { get; set; } = Guid.NewGuid().ToString();

        /// <summary>
        /// 关联的权限ID（来自GROUP_PERMISSION）
        ///</summary>
        [SugarColumn(ColumnName = "PERMISSION_ID", Length = 36)]
        public string PermissionId { get; set; }

        /// <summary>
        /// 规则名称 (e.g., "仅限北京地区访问")
        ///</summary>
        [SugarColumn(ColumnName = "RULE_NAME")]
        public string RuleName { get; set; }

        /// <summary>
        /// 属性条件表达式 (JSON格式)
        /// 示例: 
        /// {
        ///   "type": "LOCATION",
        ///   "operator": "IN",
        ///   "values": ["CN-BJ", "CN-SH"]
        /// }
        ///</summary>
        [SugarColumn(ColumnName = "CONDITION_JSON", ColumnDataType = "TEXT")]
        public string ConditionJson { get; set; }

        [SugarColumn(ColumnName = "IS_ACTIVE", Length = 1)]
        public string IsActive { get; set; } = "Y";
    }
}
